Yes
Here is a fragment, using #
double A= 0.1, B= -0.1; DecimalFormat numform = new DecimalFormat(" ##0.###;-##0.###"); System.out.println( "A = " + numform.format(A) ); System.out.println( "B = " + numform.format(B) );
The fragment writes:
A = 0.1 B = -0.1
Format patterns that contain #
create strings
of varying lengths,
so it is hard to align numbers in columns of output.
What does the following fragment write?
double A= 123.1, B= -1.1; DecimalFormat numform = new DecimalFormat(" ##0.###;-##0.###"); System.out.println( "A = " + numform.format(A) ); System.out.println( "B = " + numform.format(B) );